layui.use(['table', 'jquery', 'layer'], function (data) {
    var table = layui.table,
        $ = layui.jquery,
        layer = layui.layer;
    var projectNo = $('input[name="projectNo"]').val();
    console.log(projectNo)
    table.render({
        elem: "#projectDetailList",
        height: 'full-125',
        url: ctx + '/design/bomSelectByParams?projectNo=' + projectNo,
        page: true,
        cellMinWidth: 80, // 单元格最小宽度
        toolbar: '#toolbarDemo',
        cols: [[// 表头
            {type: 'checkbox'},
            {type: "numbers"},
            {title: "项目编号", field: "projectNo" ,templet:function (data){
                return data.projectBean.projectNo
                }},
            {title: "物料编号", field: "materialNo"},
            {title: "物料名称", field: "materialName"},
            {title: "物料数量", field: "materialCount"},
            {
                title: "物料单位", templet: function (data) {
                    if (data.materialBean == null) {
                        return "暂无"
                    } else {
                        return data.materialBean.materialUnit
                    }
                }
            },
            {
                title: "操作", templet: "#tool"
            }

        ]]
    })


    table.on('tool(projectDetailFilter)', function (data) {
        if (data.event == "pick") {
            openPickMaterial(data.data);
        }
    })

    function openPickMaterial(data) {
              console.log(data.id)
        layer.open({
            type: 2,
            title: "项目---领料",
            content: ctx + "/production/toPickMaterial?id=" + data.id,
            area: ['650px', '500px'],
            shadeClose: true,
            maxmin: true
        })
    }

})